package com.banggood.upms.common.util;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @author XuChuangFeng
 * @date 2017/6/30
 */
public class PasswordUtil {

    public static String generateSalt(){
        Random ranGen = new SecureRandom();
        byte[] aesKey = new byte[8];
        ranGen.nextBytes(aesKey);
        StringBuffer hexString = new StringBuffer();
        for(int i = 0; i < aesKey.length; i++) {
            String hex = Integer.toHexString(0xff & aesKey[i]);
            if(hex.length() == 1)
                hexString.append('0');
            hexString.append(hex);
        }
        System.out.println(hexString);
        return hexString.toString();
    }
}
